﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace ThuPhap
{
    public partial class MessageBoxControl : PhoneApplicationPage
    {
        public delegate void OKDelegate(bool IsGallery);
        public static event OKDelegate OKEventMain;
        public static event OKDelegate OKEventPreview;
        private string type = string.Empty;
        public MessageBoxControl()
        {
            InitializeComponent();
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            string captain, message, question,type;
            if (NavigationContext.QueryString.TryGetValue("type", out type) && NavigationContext.QueryString.TryGetValue("captain", out captain) && NavigationContext.QueryString.TryGetValue("message", out message) && NavigationContext.QueryString.TryGetValue("question", out question))
            {
                this.CaptainTextBlock.Text = captain;
                this.MessageTextBlock.Text = message;
                this.QuestionCheckBox.Content = question;
                this.type = type;
            }
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.GoBack();
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            bool isQuestion = (bool)this.QuestionCheckBox.IsChecked;
            if (type == "preview")
            {
                if (OKEventPreview != null)
                {
                    OKEventPreview(isQuestion);
                }
            }
            else
            {
                if (OKEventMain != null)
                {
                    OKEventMain(isQuestion);
                }
            }

            NavigationService.GoBack();
        }

    }
}
